declare interface global {
  roads: Array<StructureRoad>
}

export = function (sourceId: string, targetIds: Array<string>): ICreepConfig {
  return {
    source: (creep: Creep) => {
      let spawn: Structure = Game.getObjectById<Structure>(sourceId);
      if (creep.withdraw(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) creep.moveTo(spawn)
      else creep.memory.targetWallId = targetIds[Math.floor((Math.random() * targetIds.length))];
    },
    // 建造
    target: (creep: Creep) => {
      let wall: AnyStructure = Game.getObjectById(creep.memory.targetWallId);
      if (creep.repair(wall) == ERR_NOT_IN_RANGE) creep.moveTo(wall);
      return
    },
    // 状态切换条件，稍后会给出具体实现
    switch: (creep: Creep) => creep.updateState()
  }
}